import request from '@/utils/request'
// import qs from 'qs'

// Bypass

// 获取bypass功能信息
export function getBypassStatus (params) {
  var data = fromData(params)
  return request({
    url: '/bypass/getStatus',
    method: 'post',
    data
  })
}

// 获取配置信息
export function getBypassInfo (params) {
  var data = fromData(params)
  return request({
    url: '/bypass/getInfo',
    method: 'post',
    data
  })
}

// 设置Bypass功能状态
export function setBypassStatus (params) {
  var data = fromData(params)
  return request({
    url: '/bypass/setStatus',
    method: 'post',
    data
  })
}

// 设置Bypass配置
export function setBypassInfo (params) {
  var data = fromData(params)
  return request({
    url: '/bypass/setInfo',
    method: 'post',
    data
  })
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
